/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/misc/winMutex.cpp,v 1.5 2003/11/21 16:12:58 itsme Exp $
 *
 *
 *  wrapper around windows mutex
 *  used by random number generator
 */

#include <windows.h>

#include "winMutex.h"

//--------------------------------------------------------------------------
Mutex::Mutex()
{
    m_mutex= CreateMutex(NULL, FALSE, NULL);
    // todo: what do I do when create mutex fails?
}
Mutex::~Mutex()
{
    CloseHandle(m_mutex);
    m_mutex= NULL;
}
bool Mutex::Get()
{
    return WAIT_OBJECT_0==WaitForSingleObject(m_mutex, INFINITE);
}
bool Mutex::Release()
{
    return FALSE!=::ReleaseMutex(m_mutex);
}

